package com.grad.why.studentsystem.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.grad.why.studentsystem.domain.Runningcamera;
import com.grad.why.studentsystem.domain.Runtimecoursearrangeinfo;
import com.grad.why.studentsystem.mapper.KillinfosMapper;
import com.grad.why.studentsystem.mapper.RunningcameraMapper;
import com.grad.why.studentsystem.mapper.RuntimecoursearrangeinfoMapper;
import com.grad.why.studentsystem.mapper.RuntimecoursearrangeinfodetailMapper;
import com.grad.why.studentsystem.service.ClassesTableService;
import com.grad.why.studentsystem.service.KillInfosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Service(interfaceClass = KillInfosService.class)
public class KillInfosServiceImpl implements KillInfosService {
    @Autowired
    private KillinfosMapper killinfosMapper;

    @Autowired
    private RunningcameraMapper runningcameraMapper;

    @Autowired
    private RuntimecoursearrangeinfodetailMapper runtimecoursearrangeinfodetailMapper;

    @Autowired
    private RuntimecoursearrangeinfoMapper runtimecoursearrangeinfoMapper;


    @Override
    public int checkCameraIsRunning(Integer cameraid) {
        try{
            return runningcameraMapper.checkCameraIsRunning(cameraid);
        }catch (Exception e){
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public int insertRunningCameraInfo(Integer cameraid) {
        try{
            Runningcamera runningcamera = new Runningcamera();
            runningcamera.setRunningcameraid(cameraid);
            return runningcameraMapper.insertSelective(runningcamera);
        }catch (Exception e){
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public void initDropDatas() {
        try {
            killinfosMapper.deleteKillInfos();
            runningcameraMapper.deleteRunningCameras();
            runtimecoursearrangeinfoMapper.deleteAllInfos();
            runtimecoursearrangeinfodetailMapper.deleteRuntimeCourseArrangeInfoDetails();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
